package la.iok.hzsvn.lewin.movie.controller;

import la.iok.hzsvn.lewin.movie.core.Token;
import la.iok.hzsvn.lewin.movie.core.movieservice.param.NameParam;
import la.iok.hzsvn.lewin.movie.entity.MovieTag;
import la.iok.hzsvn.lewin.movie.service.MovieTagService;
import la.iok.hzsvn.share.response.ListDataResponse;
import la.iok.hzsvn.share.response.OperatorResponse;
import la.iok.hzsvn.share.response.OperatorResponses;
import org.springframework.web.bind.annotation.*;

/**
 * 剧本标签管理接口
 */
@RestController
@RequestMapping("movieTags")
public class MovieTagController {
    private final MovieTagService movieTagService;

    public MovieTagController(MovieTagService movieTagService) {
        this.movieTagService = movieTagService;
    }
    @GetMapping
    public ListDataResponse<MovieTag> list(){
        return new ListDataResponse<>(movieTagService.selectAll());
    }
    @PostMapping
    public OperatorResponse save(@RequestHeader Token token, @RequestBody NameParam nameParam){
        movieTagService.save(token,nameParam);
        return OperatorResponses.success();
    }
    @DeleteMapping("{id}")
    public OperatorResponse delete(@RequestHeader Token token, @PathVariable Long id){
        movieTagService.delete(token,id);
        return OperatorResponses.success();
    }
}
